package com.gs.m_business_authority

import android.content.Context
import android.os.Bundle
import android.widget.ImageView
import androidx.databinding.DataBindingUtil
import com.gs.common.API
import com.gs.common.BaseCompatActivity
import com.gs.common.callback.impl.CommonHttpCallback
import com.gs.common.constant.StateCode
import com.gs.common.global.GlobalVariables
import com.gs.common.util.ActionBarUtil
import com.gs.common.util.ToastUtil
import com.gs.m_business_authority.databinding.BusinessAuthorityLayoutBinding

class BusinessAuthorityModel(context: Context){

    private val api by lazy { API.getInstance() }

    fun dealAuthority(username: String, isBusiness: Boolean, block: (Int) -> Unit) {
        block.invoke(StateCode.STATE_LOADING)
        api.dealAuthority(username, isBusiness, CommonHttpCallback(block))
    }

    companion object{
        private var instance: BusinessAuthorityModel? = null

        fun getInstance(context: Context): BusinessAuthorityModel {
            if (instance == null) {
                synchronized(this::class) {
                    if (instance == null) {
                        instance = BusinessAuthorityModel(context)
                    }
                }
            }
            return instance!!
        }
    }
}